package appconfgi

import (
	"fmt"
	"github.com/spf13/viper"
)

type config struct {
	Mysql
	Redis
	SendSms
}

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}

type SendSms struct {
	Account  string
	Password string
}

var Config config

func Init() {
	var err error
	viper.SetConfigFile("../appconfgi/config.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic(err)
	}
	fmt.Println("配置", Config)
}
